<include file="Public:header" />
<div class="page-member subpage">
    <div class="form-header">
        <div>
            <div class="line1">
                <div class="fl"><h3>焦点政务 / 新增</h3></div>
                <div class="fr hidden">
                    <form class="search-form" method="post" action="">
                        <input name="field" value="{$filter.field}" type="text" />
                        <input name="value" value="{$filter.value}" type="text" />
                        <input name="page" value="{$filter.page}" type="hidden" />
                        <input name="order_field" value="{$filter.order_field}" type="hidden" />
                        <input name="order_sort" value="{$filter.order_sort}" type="hidden" />
                        <button class="btn-normal" type="submit">查 询</button>
                    </form>
                </div>
            </div>
            <div class="line2">
                <div class="fl form-btn-group">
                    <in name="$x|default='03-01-12'" value="$rightsCode">
                        <button onclick="submitForm();" class="btn-save btn-highlight">保 存</button>
                        <else />
                        <button disabled="disabled" class="btn-save btn-disable">保 存</button>
                    </in>
                    <span>或</span>
                    <a class="linkBtn btn-abort" href="/admin/affairsFocus/index">放弃</a>
                </div>
            </div>
        </div>
    </div>
    <div class="form-box2">
        <div>
            <form id="affairsFocusForm" method="post" action="">
                <input type="hidden" name="id" id="id" value="{$affairsFocus.id}" />
                <table class="form">
                    <tr>
                        <th width="15%">焦点政务标题<span class="hint">*</span></th>
                        <td width="35%">
                            <input name="title" type="text" value="{$affairsFocus.title}" />
                        </td>
                        <th width="15%">序号<span class="hint">*</span></th>
                        <td><input placeholder="序号越小，优先级越高" name="seq" type="text" value="{$affairsFocus.seq}" /> </td>
                    </tr>
                    <tr>
                        <th>缩略图<span class="hint">*</span></th>
                        <td>
                            <input name="upload" class="hidden" type="file" />
                            <input name="photo" type="hidden" value="{$affairsFocus.photo}" />
                            <img name="photo" style="width:150px;height:120px;" class="img-upload" src="__IMG__/index/thumb.png" />
                        </td>
                        <th>是否有效<span class="hint">*</span></th>
                        <td>
                            <input name="active" value="有效" checked="checked" type="checkbox" />
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<link type="text/css" href="__JS__/autocomplete2/src/jquery.autocomplete.min.css" rel="stylesheet">
<script src="__JS__/autocomplete2/src/jquery.autocomplete.js" type="text/javascript"></script>
<script>
    $('input[name=affairs_name]').autocomplete({
        serviceUrl: '/admin/affairsFocus/ajax_SearchAffairsByName',
        extraParams: {title:$.trim($("input[name=affairs_name]").val())},//动态参数值
        paramName: "title",//自定义的参数名 必须和extraParams 参数名相同
        onSelect: function (suggestion) {
            $("input[name=affairs_id]").val(suggestion.data.id);
        }
    });
    $(document).ready(function(){
        $(".img-upload").click(function () {
            $("input[name=upload]").prop("mb", $(this).prop("name")).click();
        });
        $("input[name=upload]").change(function () {
            var self = $(this);
            var form_data = new FormData();
            var file_data = self.prop('files')[0];
            form_data.append('file', file_data);
            $.ajax({
                url: '/home/index/ajax_UploadImg',
                dataType: 'json',
                contentType: false,
                processData: false,
                data: form_data,
                type: 'post',
                success: function(res){
                    if(res.status){
                        self.val(""); //重置文件上传框
                        $("img[name="+self.prop("mb")+"]").prop("src", res.info);
                        $("input[name="+self.prop("mb")+"]").val(res.info);
                    }else{
                        alert(res.info);
                    }
                }
            });
        });
    });
</script>
<script src="__JS__/affairsFocus.js?v=0.1" type="text/javascript" ></script>
<include file="Public:footer" />
